<?php
session_start();
$directory = "data/";

if (isset($_POST['algorithm'])&&!empty($_POST['algorithm']))
{
  $algorithm = $_POST['algorithm'];  
  $fp = fopen('data/algorithm.txt', 'w');
  if ($fp)
  {
    fwrite($fp, $algorithm);
    fclose($fp);
    $_SESSION['error'] = "Algorithm saved";
    header('Location: Index.php');
  }
}
else
{
  $_SESSION['error'] = "Algorithm saved";
  header('Location: Index.php');
}
?>